package org.robot.dao;

import java.lang.reflect.Field;

import org.robot.pojo.Issue;
import org.robot.utils.StrUtils;

public class IssueDao extends BaseDao {

    public static boolean addIssue(Issue issue) {
        try {
            issue.setInsertTime(StrUtils.getCurrentDateTime());
            issue.setStatus(1L);
            Long pid = selectPidByWebsite(Issue.class, issue.getWebsite(), issue.getTaskId());
            if (pid == null)
            	return save(issue) > 0;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return false;
    }
    
    public static void main(String[] args) {
        Issue issue = new Issue();
        issue.setIssue("2018年34期");
        issue.setJournalId(449087L);
        issue.setYear("2018");
        issue.setWebsite("http://beijingtijuissue.com/a/b");
        issue.setTaskId(253L);
//        addIssue(issue);
        
        Field[] fields = issue.getClass().getDeclaredFields();
        for (Field field : fields) {
			Class<?> class1 = field.getDeclaringClass();
			Class<?> class2 = field.getType();
			System.out.println(field.getName() + ": " + class1.getName() + "---" + class2.getName());
		}
    	
    }
}
